package com.zlcdg.study.kotlin.com.zlcdgroup.delegates

import java.util.regex.Pattern

object StringValidator {
    fun detectXSS(input: String): Boolean {
        val xssPatterns = listOf(
            Pattern.compile("<javascript>.*</javascript>"),
            Pattern.compile("<a>.*</a>"),
            Pattern.compile("<script>.*</script>"),
            Pattern.compile("onmouseover=.*"),
            // 添加更多的模式...
        )

        return xssPatterns.any { pattern ->
            pattern.matcher(input).find()
        }
    }

    fun isPhoneNumber(phone: String): Boolean {
        val compile = Pattern.compile("^(13|14|15|16|17|18|19)\\d{9}$")
        val matcher = compile.matcher(phone)
        return matcher.matches()
    }



}